{% extends "base_generic.html" %}
{% load static %}
{% block extra_css %}
<link rel="stylesheet" href="{% static 'css/user_management.css' %}">
{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="card">
        <div class="card-header bg-primary text-white">
            <h1 class="mb-0"><i class="fas fa-user-edit"></i> {% if form.instance.pk %}编辑作者{% else %}添加作者{% endif %}</h1>
        </div>
        <div class="card-body">
            <form action="" method="post">
                {% csrf_token %}
                <div class="row">
                    <div class="col-md-6 mb-3">
                        <label for="id_first_name" class="form-label">名:</label>
                        <input type="text" id="id_first_name" name="first_name" class="form-control" value="{{ form.instance.first_name|default:'' }}" required>
                    </div>
                    <div class="col-md-6 mb-3">
                        <label for="id_last_name" class="form-label">姓:</label>
                        <input type="text" id="id_last_name" name="last_name" class="form-control" value="{{ form.instance.last_name|default:'' }}" required>
                    </div>
                    <div class="col-md-6 mb-3">
                        <label for="id_date_of_birth" class="form-label">出生日期:</label>
                        <input type="date" id="id_date_of_birth" name="date_of_birth" class="form-control" value="{{ form.instance.date_of_birth|date:'Y-m-d'|default:'' }}">
                    </div>
                    <div class="col-md-6 mb-3">
                        <label for="id_date_of_death" class="form-label">逝世日期:</label>
                        <input type="date" id="id_date_of_death" name="date_of_death" class="form-control" value="{{ form.instance.date_of_death|date:'Y-m-d'|default:'' }}">
                    </div>
                </div>
                <div class="text-end">
                    <a href="{% url 'authors' %}" class="btn btn-secondary">取消</a>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}